package part7;

import java.util.Arrays;
import java.util.Random;

/**
 * @author wcj
 * @Date 2021/5/15 16:08
 * @Version 1.0
 */
public class Part710 {
    private static Random random = new Random(47);
    private String id;

    public Part710(String id) {
        this.id = id;
    }

    private final int valueOne = 9;
    private static final int VALUE_TWO = 39;
    public static final int VALUE_THREE = 99;
    private final int i4 = random.nextInt(20);
    static final int INT_5 = random.nextInt(20);
    private Value v1 = new Value(11);
    private final Value v2 = new Value(22);
    private static final Value VAL_3 = new Value(33);
    private final int[] a = {1, 2, 3, 4, 5, 6};

    @Override
    public String toString() {
        return id + ":" + "i4=" + i4 + ",INT_5=" + INT_5;
    }

    /**
     * 对于基本数据类型，使用final关键字表明其值不能再改变
     * 对于对象类型，使用final修饰表明其引用不能再改变，但是其值可以改变
     * 另外需要注意，如果使用static final修饰则变量名要大写且用下划线连接
     *
     * @param args
     */
    public static void main(String[] args) {
        Part710 part710 = new Part710("710");
//        part710.valueOne++; 常量不能改变其值
        part710.v2.i++;
        part710.v1 = new Value(10);
        for (int i = 0; i < part710.a.length; i++) {
            part710.a[i]++;
        }
        System.out.println(Arrays.toString(part710.a));
    }
}

class Value {
    int i;

    public Value(int i) {
        this.i = i;
    }
}
